package logindao

import "gorm.io/gorm"

type Login struct{}

func (l *Login) LoginRole(userType string, db *gorm.DB) func(db *gorm.DB) *gorm.DB {
	return func(db *gorm.DB) *gorm.DB {
		switch userType {
		case "admin":
			return db.Where("role_id IN (?)", []int{1, 19, 31})
		case "site":
			return db.Where("role_id = ?", 32)
		case "nor":
			return db.Not("role_id IN (?)", []int{1, 19, 31, 32})
		default:
			return db.Where("role_id IS NULL")
		}
	}
}

var LoginDao = new(Login)
